package com.wj.converter;

import com.wj.constant.GoodsCategory;

import javax.persistence.AttributeConverter;

/**
 * 商品分类枚举属性转换性
 */
public class GoodsCategoryConverter implements AttributeConverter<GoodsCategory,String> {


    @Override
    public String convertToDatabaseColumn(GoodsCategory goodsCategory) {
        return goodsCategory.getCode();
    }

    @Override
    public GoodsCategory convertToEntityAttribute(String code) {
        return GoodsCategory.of(code);
    }
}
